\(\int \cot ^2(e+f x) (a+b \tan ^2(e+f x)) \, dx\) [195]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [C] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 21 \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=-((a-b) x)-\frac {a \cot (e+f x)}{f} \]

[Out]

-(a-b)*x-a*cot(f*x+e)/f

Rubi [A] (verified)

Time = 0.03 (sec) , antiderivative size = 21, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.095, Rules used = {3710, 8} \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=-(x (a-b))-\frac {a \cot (e+f x)}{f} \]

[In]

Int[Cot[e + f*x]^2*(a + b*Tan[e + f*x]^2),x]

[Out]

-((a - b)*x) - (a*Cot[e + f*x])/f

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 3710

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[
(A*b^2 + a^2*C)*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1)*(a^2 + b^2))), x] + Dist[1/(a^2 + b^2), Int[(a + b*
Tan[e + f*x])^(m + 1)*Simp[a*(A - C) - (A*b - b*C)*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, e, f, A, C}, x] &&
 NeQ[A*b^2 + a^2*C, 0] && LtQ[m, -1] && NeQ[a^2 + b^2, 0]

Rubi steps \begin{align*} \text {integral}& = -\frac {a \cot (e+f x)}{f}+\int (-a+b) \, dx \\ & = -((a-b) x)-\frac {a \cot (e+f x)}{f} \\ \end{align*}

Mathematica [C] (verified)

Result contains higher order function than in optimal. Order 5 vs. order 3 in optimal.

Time = 0.02 (sec) , antiderivative size = 34, normalized size of antiderivative = 1.62 \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=b x-\frac {a \cot (e+f x) \operatorname {Hypergeometric2F1}\left (-\frac {1}{2},1,\frac {1}{2},-\tan ^2(e+f x)\right )}{f} \]

[In]

Integrate[Cot[e + f*x]^2*(a + b*Tan[e + f*x]^2),x]

[Out]

b*x - (a*Cot[e + f*x]*Hypergeometric2F1[-1/2, 1, 1/2, -Tan[e + f*x]^2])/f

Maple [C] (verified)

Result contains complex when optimal does not.

Time = 0.09 (sec) , antiderivative size = 29, normalized size of antiderivative = 1.38

method result size
risch \(-a x +b x -\frac {2 i a}{f \left ({\mathrm e}^{2 i \left (f x +e \right )}-1\right )}\) \(29\)
derivativedivides \(\frac {-\frac {a}{\tan \left (f x +e \right )}+\left (-a +b \right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(30\)
default \(\frac {-\frac {a}{\tan \left (f x +e \right )}+\left (-a +b \right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(30\)
norman \(\frac {\left (-a +b \right ) x \tan \left (f x +e \right )-\frac {a}{f}}{\tan \left (f x +e \right )}\) \(30\)
parallelrisch \(\frac {-\tan \left (f x +e \right ) f x \left (a -b \right )-a}{\tan \left (f x +e \right ) f}\) \(32\)

[In]

int(cot(f*x+e)^2*(a+b*tan(f*x+e)^2),x,method=_RETURNVERBOSE)

[Out]

-a*x+b*x-2*I*a/f/(exp(2*I*(f*x+e))-1)

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 29, normalized size of antiderivative = 1.38 \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=-\frac {{\left (a - b\right )} f x \tan \left (f x + e\right ) + a}{f \tan \left (f x + e\right )} \]

[In]

integrate(cot(f*x+e)^2*(a+b*tan(f*x+e)^2),x, algorithm="fricas")

[Out]

-((a - b)*f*x*tan(f*x + e) + a)/(f*tan(f*x + e))

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 42 vs. \(2 (14) = 28\).

Time = 0.29 (sec) , antiderivative size = 42, normalized size of antiderivative = 2.00 \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=\begin {cases} \tilde {\infty } a x & \text {for}\: e = 0 \wedge f = 0 \\x \left (a + b \tan ^{2}{\left (e \right )}\right ) \cot ^{2}{\left (e \right )} & \text {for}\: f = 0 \\\tilde {\infty } a x & \text {for}\: e = - f x \\- a x - \frac {a}{f \tan {\left (e + f x \right )}} + b x & \text {otherwise} \end {cases} \]

[In]

integrate(cot(f*x+e)**2*(a+b*tan(f*x+e)**2),x)

[Out]

Piecewise((zoo*a*x, Eq(e, 0) & Eq(f, 0)), (x*(a + b*tan(e)**2)*cot(e)**2, Eq(f, 0)), (zoo*a*x, Eq(e, -f*x)), (
-a*x - a/(f*tan(e + f*x)) + b*x, True))

Maxima [A] (verification not implemented)

none

Time = 0.31 (sec) , antiderivative size = 27, normalized size of antiderivative = 1.29 \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=-\frac {{\left (f x + e\right )} {\left (a - b\right )} + \frac {a}{\tan \left (f x + e\right )}}{f} \]

[In]

integrate(cot(f*x+e)^2*(a+b*tan(f*x+e)^2),x, algorithm="maxima")

[Out]

-((f*x + e)*(a - b) + a/tan(f*x + e))/f

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 43 vs. \(2 (21) = 42\).

Time = 0.52 (sec) , antiderivative size = 43, normalized size of antiderivative = 2.05 \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=-\frac {2 \, {\left (f x + e\right )} {\left (a - b\right )} - a \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + \frac {a}{\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )}}{2 \, f} \]

[In]

integrate(cot(f*x+e)^2*(a+b*tan(f*x+e)^2),x, algorithm="giac")

[Out]

-1/2*(2*(f*x + e)*(a - b) - a*tan(1/2*f*x + 1/2*e) + a/tan(1/2*f*x + 1/2*e))/f

Mupad [B] (verification not implemented)

Time = 11.15 (sec) , antiderivative size = 21, normalized size of antiderivative = 1.00 \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right ) \, dx=-x\,\left (a-b\right )-\frac {a\,\mathrm {cot}\left (e+f\,x\right )}{f} \]

[In]

int(cot(e + f*x)^2*(a + b*tan(e + f*x)^2),x)

[Out]

- x*(a - b) - (a*cot(e + f*x))/f